#include "HelloWorldScene.h"
#include "ComView.h"
#include "SimpleAudioEngine.h"
#include "dev/DevInclude.h"


using namespace cocos2d;
using namespace CocosDenshion;

#define MY_POS 1

CCScene* DDZRoom::scene()
{
    CCSize winSize=  CCDirector::sharedDirector()->getWinSize();
    CCScene *scene = CCScene::create();
    scene->setContentSize(winSize);
    DDZRoom *layer = DDZRoom::create();
    
    layer->setPositionY(winSize.height);
    scene->addChild(layer);
    layer->loadConf(layer->confPath);
    return scene;
}
 
bool DDZRoom::init()
{ 
    if ( !TPanel::init() )
    {
        return false;
    }
    confPath=("proj/view/GameView.mxml");
    return true;
}
void DDZRoom::onCreateComplete(){
    getPanel("cardPanel")->setTarget(this, menu_selector(DDZRoom::onSelectEnd));
    bool play=CCUserDefault::sharedUserDefault()->getBoolForKey("effect",true);
    if(play){
        
        getPanel("topPanel")->getUI("playEffect")->setVisible(false);
        getPanel("topPanel")->getUI("stopEffect")->setVisible(true);
        CSoundManager::sharedSoundManager()->setIsPlayEffect(true);
    }else{
        
        getPanel("topPanel")->getUI("playEffect")->setVisible(true);
        getPanel("topPanel")->getUI("stopEffect")->setVisible(false);
        CSoundManager::sharedSoundManager()->setIsPlayEffect(false);
    }
}

void DDZRoom::onSelectEnd(CCObject*){
    if(checkOut()){
        
        getPanel("selectPanel")->getButton("outBtn")->setEnable(true);
    }else{
        
        getPanel("selectPanel")->getButton("outBtn")->setEnable(true);
    }
    
}


void DDZRoom::onEnter(){
     TPanel::onEnter(); 
    schedule(schedule_selector(DDZRoom::updateGame));
    CSoundManager::sharedSoundManager()->playBackground("sounds/DDZBgMusic.wav");
}

void DDZRoom::onExit(){
    TPanel::onExit(); 
    this->unschedule(schedule_selector(DDZRoom::updateGame));
}


DDZRoom::DDZRoom(){ 
    isPlaying = false;
    isReady = false;
    currentPlayer=0;
    curPoint=0;
    lastOutCardPayer=0;
    refreshSearchResult=true;
    isGameOver = false; 
    searchResultIdx=0;
    curRate=0;
    myPocker=&userPoker[1];
    
  
    curPoint=CCUserDefault::sharedUserDefault()->getIntegerForKey("point",0);
}

void DDZRoom::procTuiEvent(const string& event,TPanelItem* target){
    if(event=="stopEffect"){
        getPanel("topPanel")->getUI("playEffect")->setVisible(true);
        getPanel("topPanel")->getUI("stopEffect")->setVisible(false);
        CSoundManager::sharedSoundManager()->setIsPlayEffect(false);
        CCUserDefault::sharedUserDefault()->setBoolForKey("effect",false);
        CCUserDefault::sharedUserDefault()->flush();
    }else  if(event=="playEffect"){
        getPanel("topPanel")->getUI("playEffect")->setVisible(false);
        getPanel("topPanel")->getUI("stopEffect")->setVisible(true);
        CSoundManager::sharedSoundManager()->setIsPlayEffect(true);
        CCUserDefault::sharedUserDefault()->setBoolForKey("effect",true);
        CCUserDefault::sharedUserDefault()->flush();
    }else if(event=="ready"){
        StartPlay();
        getUI("readyBtn")->setVisible(false);
    }else if(event=="callPoint"){
        getUI("subPanel")->setVisible(false);
        onCallPoint(target->getTag()==-1?0:target->getTag());
    }else if(event=="noOut"){
        getHeadIcon(MY_POS)->showPass();
        getPanel("selectPanel")->setVisible(false);
        this->schedule(schedule_selector(DDZRoom::onOutCardEnd),1.0f);
        resetCard();
    }else if(event=="retry"){
        resetCard();
    }else if(event=="outCard"){
        
        if( checkOut()){
            getPanel("selectPanel")->setVisible(false);
            showOutCards(MY_POS, selfOutCards, outCardCount);
        }
    
    
    }else if(event=="notice"){
        resetCard();
        
        getPanel("selectPanel")->getButton("outBtn")->setEnable(true);
        if(refreshSearchResult){
            refreshSearchResult=false;
            searchResultIdx=0;
            memset(&searchResult, 0, sizeof(tagSearchCardResult));
            
            
            if(lastOutCardPayer==currentPlayer){
                
                gameLogic.SearchOutCard(userPoker[currentPlayer].bCardData,
                                        userPoker[currentPlayer].iCardnum,
                                        NULL,0,&searchResult);
            }else{
                
                gameLogic.SearchOutCard(userPoker[currentPlayer].bCardData,
                                        userPoker[currentPlayer].iCardnum,
                                        otherOutCards,lastOutCount,&searchResult);
            }
        }
        noticeOut(searchResult);
        
        if(searchResultIdx==searchResult.cbSearchCount-1){
            searchResultIdx=0;
        }else{
            searchResultIdx++;
        }
    }
}

void DDZRoom::resetCard(){
    for(int i=0;i<myCard.size();i++)
    {
        if(myCard[i]){
            if(myCard[i]->isSelect){
                myCard[i]->setSelected();
            }
        }
    }
}


void DDZRoom::updateGame(float dt){ 
    getPanel("topPanel")->getLabel("txtScore")->setString(curPoint);
    
    getPanel("topPanel")->getLabel("txtRate")->setString(curRate);
    for(int i=0;i<GAME_PLAYER;i++){
        getHeadIcon(i)->setPockeNum(isPlaying?userPoker[i].iCardnum :0);
       
    } 
}
 
void DDZRoom::gameEnd(){
    isPlaying=false;
    isReady=false;
    getUI("readyBtn")->setVisible(true);
    for(int i=0;i<GAME_PLAYER;i++){
        showAllOutCards(i, userPoker[i].bCardData,  userPoker[i].iCardnum);
    }
    
    
    if(winPlayer==MY_POS){
        curPoint+=curRate*curCallPoint;
        curRate=0;
        CSoundManager::sharedSoundManager()->playEffect("sounds/DDZWin.wav");
        DevUtils::sharedDevUtils()->showBigAd();
    }else{
        curPoint-=curRate*curCallPoint;
        curRate=0;
        CSoundManager::sharedSoundManager()->playEffect("sounds/DDZLose.wav");
        
    }
    CCUserDefault::sharedUserDefault()->setIntegerForKey("point",curPoint);
    CCUserDefault::sharedUserDefault()->flush();
}
 

void DDZRoom::robotcall(int pos,int score){
    
}


PockerCard* DDZRoom::getCardByNum(int num){
    for(int i=0;i<cards.size();i++){
        if( cards[i]->cardID==num){
            return cards[i];
        }
    }
    return  NULL;
}

void DDZRoom::noticeOut(tagSearchCardResult& out){
    if(out.cbSearchCount==0){
        return;
    }
     
    for(int i=0;i<out.cbCardCount[searchResultIdx];i++){
        if(out.cbResultCard[searchResultIdx][i]){
           PockerCard* card= getCardByNum(out.cbResultCard[searchResultIdx][i]);
            if(card){
                card->setSelected();
            }
        }
    }
}


void DDZRoom::clearSelectCard(){
    memset(selfOutCards, MAX_COUNT, 0); 
}
void DDZRoom::clearOutCard(){
    memset(otherOutCards, MAX_COUNT, 0);
     
}

bool DDZRoom::checkOut(){
    clearSelectCard();
    
    outCardCount=0; 
    for(int i=0;i<myCard.size();i++){
        if(myCard[i]&& myCard[i]->isSelect){
            selfOutCards[outCardCount]=myCard[i]->cardID;
            outCardCount++;
        }
    } 
    
    
    if(gameLogic.GetCardType(selfOutCards, outCardCount) != CT_ERROR)
    {
        return true;
    }else{
        return false;
    }
    
}

void DDZRoom::onNextTurn(){
    refreshSearchResult=true;
    TPanel* panel= getOutCardPanel((lastOutCardPayer-1)%GAME_PLAYER);
    if(panel){
        panel->removeAllChildren();
    } 
    panel= getOutCardPanel(currentPlayer);
    if(panel){
        panel->removeAllChildren();
    }
    for(int i=0;i<GAME_PLAYER;i++){
        getHeadIcon(i)->clearPanel();
        
    }
    
    if(currentPlayer==MY_POS){
        getPanel("selectPanel")->setVisible(true);
        getPanel("selectPanel")->getButton("outBtn")->setEnable(true);
    }else{
        getPanel("selectPanel")->setVisible(false);
        
        tagOutCardResult ret;
        memset(&ret,0, sizeof(tagOutCardResult));
        
        if(lastOutCardPayer==currentPlayer){ 
            gameLogic.AndroidOutCard(userPoker[currentPlayer].bCardData,
                                     userPoker[currentPlayer].iCardnum,
                                     NULL,0, NULL,currentPlayer,ret);
        }else{ 
            gameLogic.AndroidOutCard(userPoker[currentPlayer].bCardData,
                                     userPoker[currentPlayer].iCardnum,
                                     otherOutCards,lastOutCount, lastOutCardPayer,currentPlayer,ret);
        }
        
        if(ret.cbCardCount==0){
            getHeadIcon(currentPlayer)->showPass();
            this->schedule(schedule_selector(DDZRoom::onOutCardEnd),1.0f);
            return;
        }
        
        showOutCards(currentPlayer, ret.cbResultCard, ret.cbCardCount);
    } 
    
     
}

void DDZRoom::StartPlay(){
	isReady = true; 
    isPlaying = false;
    winPlayer=-1;
    CSoundManager::sharedSoundManager()->playEffect("sounds/DDZReady.wav");
    
    for(int i=0;i<GAME_PLAYER;i++){
        getCardPanel(i)->removeAllChildren();
        getOutCardPanel(i)->removeAllChildren();
        getHeadIcon(i)->showHead1();
    }
    
	memset(gameLogic.m_cbAllCardData,0x0,sizeof(gameLogic.m_cbAllCardData));
	memset(gameLogic.m_cbUserCardCount,0x0,sizeof(gameLogic.m_cbUserCardCount));
    
	gameLogic.m_wBankerUser = -1;
	gameLogic.m_lBankerOutCardCount = 0;
	
	memset(userPoker, 0x0, sizeof(userPoker));
	memset(publiccard, 0x0, sizeof(publiccard));
	BYTE cbRandCard[FULL_COUNT];
	gameLogic.RandCardList(cbRandCard,54);
	for (int i = 0; i < NORMAL_COUNT; i++) {
		userPoker[0].bCardData[i] = cbRandCard[i*GAME_PLAYER];
		userPoker[1].bCardData[i] = cbRandCard[i*GAME_PLAYER + 1];
		userPoker[2].bCardData[i] = cbRandCard[i*GAME_PLAYER + 2];
	}
	userPoker[0].iCardnum = NORMAL_COUNT;
	userPoker[1].iCardnum = NORMAL_COUNT;
	userPoker[2].iCardnum = NORMAL_COUNT;
	//底牌设置
	for (int i = 51; i <= 53; i++)
	{
		publiccard[i-51] = cbRandCard[i];
	}
	//手牌设置
	for (int i = 0; i < GAME_PLAYER; i++)
	{
		gameLogic.SetUserCard(i, userPoker[i].bCardData, NORMAL_COUNT);
	} 
    
    
    isGameOver = false;
    showCards();

}


void DDZRoom::onCardsShowed(){
    for(int i = 0; i <myCard.size(); i++)
    {
        if(myCard[i]){
            
            myCard[i]->showNum();
            myCard[i]->setZOrder(i);
        }
    }
    
    
    TPanel* panel=getPanel("cardTopPanel");
    
    for(int i = 0; i < GAME_PLAYER; i++)
    { 
        PockerCard* card =PockerCard::create();
        card->setNum(publiccard[i]);
        card->setLeft(0);
        card->showNum();
        card->isSelelct = false;
        panel->addChild(card);
        CCPoint pos;
        card->setBottom(0);
        pos.setPoint(i*(panel->getContentSize().width*1.0f/GAME_PLAYER),card->getPositionY());
        card->setPosition(pos);
        
        
    }
    
    bankerUser=0;
    hasCallNum=0;
    curCallPoint=0;
    firstCallPos=getRandom(0, 29)/10;
    bankerUser=-1;
    showCall(firstCallPos);
}

void DDZRoom::showCall(int pos){
    curCallPos=pos;
    if(curCallPos==MY_POS){
        getUI("subPanel")->setVisible(true);
        
        for(int i=1;i<=GAME_PLAYER;i++){
            char numName[50]={0};
            sprintf(numName, "point%d",i);
            getPanel("subPanel")->getButton(numName)->setEnable(true);
            getPanel("subPanel")->getButton(numName)->setOpacity(255);
            
        }
        
        for(int i=1;i<=curCallPoint;i++){
            char numName[50]={0};
            sprintf(numName, "point%d",i);
            getPanel("subPanel")->getButton(numName)->setEnable(true);
            getPanel("subPanel")->getButton(numName)->setOpacity(50);
        }
    }else{
        this->schedule(schedule_selector(DDZRoom::onOtherCallPoint),1.0f);
    }
}

void DDZRoom::onOtherCallPoint(float dt){
    this->unschedule(schedule_selector(DDZRoom::onOtherCallPoint)); 
    int point=getRandom(0, 39)/10;
    if(point<=curCallPoint){
        point=0;
    }
    onCallPoint(point);
}

void DDZRoom::onCallPoint(int point){
    
    if(point==0){
        CSoundManager::sharedSoundManager()->playEffect("sounds/DDZNoCall.wav");
    }else if(point==1){
        CSoundManager::sharedSoundManager()->playEffect("sounds/DDZCallOne.wav");
    }else if(point==2){
        CSoundManager::sharedSoundManager()->playEffect("sounds/DDZCallTwo.wav");
    }else if(point==3){
        CSoundManager::sharedSoundManager()->playEffect("sounds/DDZCallLandlord.wav");
    } 
    
    HeadIcon* head=getHeadIcon(curCallPos);
    if(head){
        head->showCallNum(point);
    }
    
    if(point>curCallPoint && point!=0){ 
        curCallPoint=point;
        bankerUser=curCallPos;
    }
    
    
    hasCallNum++;
    if(point==3 || hasCallNum==3){
        if(bankerUser==-1){
            //重新开始
        }else{
            this->schedule(schedule_selector(DDZRoom::playGame),1.0f); 
        }
    }else{
        showCall((curCallPos+1)%GAME_PLAYER);
    }
}



HeadIcon* DDZRoom::getHeadIcon(int pos){
    char numName[50]={0};
    sprintf(numName, "head%d",pos%GAME_PLAYER);
    return (HeadIcon*) getUI(numName);
}


void DDZRoom::playGame(float dt){
    isPlaying=true;
    if(bankerUser==MY_POS){
        curRate=2;
    }else{
        curRate=1;
    }
    
    getHeadIcon(bankerUser)->showHead2();
    this->unschedule(schedule_selector(DDZRoom::playGame));
    getUI("subPanel")->setVisible(false);
    for(int i=0;i<GAME_PLAYER;i++)
    getHeadIcon(i)->clearPanel();
    currentPlayer=bankerUser;
    gameLogic.m_wBankerUser=bankerUser;
    
    userPoker[bankerUser].bCardData[17]=publiccard[0];
    userPoker[bankerUser].bCardData[18]=publiccard[1];
    userPoker[bankerUser].bCardData[19]=publiccard[2];
    userPoker[bankerUser].iCardnum=MAX_COUNT;
	gameLogic.SetBackCard(bankerUser, publiccard, 3);
    
    
    memset(otherOutCards, 0, MAX_COUNT);
    lastOutCardPayer=currentPlayer;
    layoutAllCard();
    onNextTurn();
}

void DDZRoom::showAllOutCards(int pos,BYTE * cards,int count){
    
    TPanel* panel=NULL;
    TPanel* outPanel=NULL;
    
    outPanel=getOutCardPanel(pos);
    outPanel->removeAllChildren();
    panel=getCardPanel(pos);
    
    for(int i = 0; i < count; i++)
    {
        PockerCard* pockerCard= getCardByNum(cards[i]);
        if(pockerCard){
            pockerCard->retain();
            if(pockerCard->getParent()){
                pockerCard->getParent()->removeChild(pockerCard);
            }
            panel->removeItem(pockerCard);
            outPanel->addChild(pockerCard,i);
            pockerCard->release();
            pockerCard->showNum();
            pockerCard->setPositionX(i*pockerCard->getContentSize().width/3);
            pockerCard->setBottom(0);
        } 
    }

}

void DDZRoom::showOutCards(int pos,BYTE * cards,int count){
    
    lastOutCardPayer=pos;
    memset(otherOutCards, 0, MAX_COUNT);
    lastOutCount=count;
    
    TPanel* panel=NULL;
    TPanel* outPanel=NULL;
   
    outPanel=getOutCardPanel(currentPlayer);
    outPanel->removeAllChildren();
    panel=getCardPanel(currentPlayer);
    
    
    CSoundManager::sharedSoundManager()->playEffect("sounds/DDZPlayCard.wav");
    //炸弹翻倍
	BYTE pockerType = gameLogic.GetCardType(cards, count);
	if(pockerType == CT_BOMB_CARD || pockerType == CT_MISSILE_CARD)
	{
		curRate = curRate*2;
        CSoundManager::sharedSoundManager()->playEffect("sounds/DDZBomb.wav");
	}
    
    if(pockerType == CT_BOMB_CARD){ 
        CSoundManager::sharedSoundManager()->playEffect("sounds/DDZBomb.wav");
    }
    if(pockerType == CT_MISSILE_CARD){
        CSoundManager::sharedSoundManager()->playEffect("sounds/DDZRocket.wav");
    } 
    if (pockerType == CT_FOUR_LINE_TAKE_ONE || pockerType == CT_FOUR_LINE_TAKE_TWO)
	{
        CSoundManager::sharedSoundManager()->playEffect("sounds/sidaier.wav"); 
	}
	else if(pockerType == CT_THREE_LINE_TAKE_ONE  )
	{
		if (count > 4 ) {
            CSoundManager::sharedSoundManager()->playEffect("sounds/DDZPlane.wav"); 
		}else {
            CSoundManager::sharedSoundManager()->playEffect("sounds/sandaiyi.wav"); 
        }
        
		
	}
	else if (pockerType == CT_THREE_LINE_TAKE_TWO)
	{
		if (count > 5 ) {
            CSoundManager::sharedSoundManager()->playEffect("sounds/DDZPlane.wav");
		}else {
            CSoundManager::sharedSoundManager()->playEffect("sounds/sandaiyidui.wav"); 
		}
	}
	else if (pockerType == CT_THREE_LINE)
	{
		//三连类型
	}
	else if (pockerType == CT_DOUBLE_LINE )
	{
        
        CSoundManager::sharedSoundManager()->playEffect("sounds/liandui.wav");
		//对连类型 
	}
	else if (pockerType == CT_SINGLE_LINE )
	{
        CSoundManager::sharedSoundManager()->playEffect("sounds/shunzi.wav");
		//单连类型 
	}
	else if (pockerType == CT_THREE )
	{
		//三条类型
	}
	else if (pockerType == CT_DOUBLE )
	{
		//对牌类型
	}
	else if (pockerType == CT_SINGLE )
	{
		//单牌类型
		if (cards[0] == 0x4f) {
            CSoundManager::sharedSoundManager()->playEffect("sounds/dawang.wav"); 
		}else if (cards[0] == 0x4e) {
            CSoundManager::sharedSoundManager()->playEffect("sounds/xiaowang.wav"); 
		}
	} 
    
    
    
    for(int i = 0; i < count; i++)
    { 
        PockerCard* pockerCard= getCardByNum(cards[i]);
        if(pockerCard){
            pockerCard->retain();
            if(pockerCard->getParent()){
                pockerCard->getParent()->removeChild(pockerCard);
            }
            panel->removeItem(pockerCard);
            outPanel->addChild(pockerCard,i);
            pockerCard->release();
            pockerCard->showNum();
            pockerCard->setPositionX(i*pockerCard->getContentSize().width/3);
            pockerCard->setBottom(0);
        }
        otherOutCards[i]=cards[i];
    }
    
    
    
    
    vector<BYTE> remain;
    bool isout=false;
    for(int j=0;j<userPoker[currentPlayer].iCardnum;j++){
        isout=false;
        for(int i = 0; i < count; i++)
        {
            if(userPoker[currentPlayer].bCardData[j]==cards[i]){
                isout=true;
            }
        }
        
        if(!isout){
            remain.push_back(userPoker[currentPlayer].bCardData[j]);
        }
       
    }
    
    if(remain.size()==0){
        isPlaying=false;
        winPlayer=currentPlayer;
    }
    
   
    
    memset(userPoker[currentPlayer].bCardData, 0, MAX_COUNT);
    for(int i=0;i<remain.size();i++){
        userPoker[currentPlayer].bCardData[i]=remain[i];
    }
    userPoker[currentPlayer].iCardnum=remain.size();
    gameLogic.RemoveUserCardData(currentPlayer, cards, count);
    layoutAllCard();
    this->schedule(schedule_selector(DDZRoom::onOutCardEnd),1.0f);
}

void DDZRoom::onOutCardEnd(float dt){
    this->unschedule(schedule_selector(DDZRoom::onOutCardEnd));
    if(!isPlaying && winPlayer!=-1){
        gameEnd();
        return;
    }
    currentPlayer++;
    currentPlayer=currentPlayer%GAME_PLAYER;
    onNextTurn();
    
}

TPanel* DDZRoom::getOutCardPanel(int j){
    
    TPanel* panel=NULL;
    if(j==0){
        panel=getPanel("outLeftCardPanel");
    }else if(j==MY_POS){
        panel=getPanel("outCardPanel");
    }else{
        panel=getPanel("outRightCardPanel");
    }
    return panel;

}
TPanel* DDZRoom::getCardPanel(int j){
    
    TPanel* panel=NULL;
    if(j==0){
        panel=getPanel("cardLeftPanel");
    }else if(j==MY_POS){
        panel=getPanel("cardPanel");
    }else{
        panel=getPanel("cardRightPanel");
    }
    return panel;
}


void DDZRoom::showCard(int j,bool isStart){
    CCSize size=CCDirector::sharedDirector()->getWinSize();
    
    TPanel* panel=getCardPanel(j);
    panel->clearItems();
    CCPoint centerPoint(size.width/2,size.height/2);
    centerPoint=getPosInTarget(centerPoint, panel);
    gameLogic.SortCardList(userPoker[j].bCardData, userPoker[j].iCardnum, ST_ORDER);
    for(int i = 0; i < userPoker[j].iCardnum; i++)
    {
        PockerCard* card=(PockerCard*)panel->getChildByTag(userPoker[j].bCardData[i]);
        if(!card){ 
            card =PockerCard::create();
            card->setTag(userPoker[j].bCardData[i]);
            card->setNum(userPoker[j].bCardData[i]);
            panel->addChild(card,NORMAL_COUNT*GAME_PLAYER-i*j); 
        }
        card->stopAllActions();
        cards.push_back(card);
        panel->addItem(card);
        
        card->isSelelct = false;
        CCPoint pos;
       
        if(j==1){
            myCard.push_back(card);
            card->setBottom(0); 
            pos.setPoint(i*40-(userPoker[j].iCardnum*40-panel->getContentSize().width)/2,card->getPositionY());
        }else{
            pos.setPoint(card->getPositionX(),-i*6);
        }
        card->setZOrder(i);
        
         
        if(!isStart){
            if(j==MY_POS){
                card->showNum();
            }
            card->runAction(CCSequence::create(
                                                   CCEaseExponentialOut::create(CCMoveTo::create(0.5f, pos)), 
                                                   NULL
                                                   )
                                ); 
            continue;
        } 
        card->setPosition(centerPoint);
      
        
        
        if(j==1 && i==userPoker[j].iCardnum-1){
            card->runAction(CCSequence::create(
                                                   CCActionInterval::create(0.07f*(i+3+j)),
                                                   CCEaseExponentialOut::create(CCMoveTo::create(0.5f, pos)),
                                                   CCCallFunc::create(this, callfunc_selector(DDZRoom::onCardsShowed)),
                                                   NULL
                                                   )
                                );
            
        }else{
            
            card->runAction(CCSequence::create(
                                                   CCActionInterval::create(0.07f*(i+3+j)),
                                                   CCEaseExponentialOut::create(CCMoveTo::create(0.5f, pos)),
                                                   NULL
                                                   )
                                );
        }
        
    }
}

void DDZRoom::layoutAllCard(){
    cards.clear();
    myCard.clear();
    for(int j=0;j<GAME_PLAYER;j++){
        gameLogic.SortCardList(userPoker[j].bCardData, userPoker[j].iCardnum, ST_ORDER);
        showCard(j,false);
    }
}

void DDZRoom::showCards(){
    cards.clear();
    myCard.clear();
    for(int j=0;j<GAME_PLAYER;j++){
        gameLogic.SortCardList(userPoker[j].bCardData, userPoker[j].iCardnum, ST_ORDER);
        showCard(j,true);
    }
 
}